package eerbaar.internal.context;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import eerbaar.context.IParam;
import eerbaar.context.IParams;

public class Params implements IParams {

    private final Map<String, String> map = new HashMap<String, String>();

    @Override
    public String get(String name) {
        return this.map.get(name);
    }

    @Override
    public IParam[] getParamArray() {

        List<IParam> result = new ArrayList<IParam>();

        Iterator<String> i = this.map.keySet().iterator();
        while (i.hasNext()) {
            String name = i.next();
            String value = this.map.get(name);
            Param param = new Param(name, value);
            result.add(param);
        }

        return result.toArray(new IParam[] {});
    }

    @Override
    public void set(String name, String value) {
        this.map.put(name, value);
    }

}
